<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/*
<span class='line'>  2</span>  * Parses the Protovis specifications on load, allowing the use of JavaScript
<span class='line'>  3</span>  * 1.8 function expressions on browsers that only support JavaScript 1.6.
<span class='line'>  4</span>  *
<span class='line'>  5</span>  * @see pv.parse
<span class='line'>  6</span>  */</span><span class="WHIT">
<span class='line'>  7</span> </span><span class="NAME">pv.listen</span><span class="PUNC">(</span><span class="NAME">window</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"load"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>  8</span> </span><span class="WHIT">   </span><span class="COMM">/*
<span class='line'>  9</span>     * Note: in Firefox any variables declared here are visible to the eval'd
<span class='line'> 10</span>     * script below. Even worse, any global variables declared by the script
<span class='line'> 11</span>     * could overwrite local variables here (such as the index, `i`)!  To protect
<span class='line'> 12</span>     * against this, all variables are explicitly scoped on a pv.$ object.
<span class='line'> 13</span>     */</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT">    </span><span class="NAME">pv.$</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">i</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">:</span><span class="NAME">document.getElementsByTagName</span><span class="PUNC">(</span><span class="STRN">"script"</span><span class="PUNC">)</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 15</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">pv.$.i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">pv.$.x.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">pv.$.i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 16</span> </span><span class="WHIT">      </span><span class="NAME">pv.$.s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.$.x</span><span class="PUNC">[</span><span class="NAME">pv.$.i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pv.$.s.type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"text/javascript+protovis"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="WHIT">        </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT">          </span><span class="NAME">window.eval</span><span class="PUNC">(</span><span class="NAME">pv.parse</span><span class="PUNC">(</span><span class="NAME">pv.$.s.text</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT">          </span><span class="NAME">pv.error</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 23</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="WHIT">    </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">pv.$</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 27</span> </span></pre></body></html>